package cn.longge.controller;

import cn.longge.entity.QualificationCondition;
import cn.longge.entity.Result;
import cn.longge.service.IQualificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/manager/qualification")
public class QualificationController {

    @Autowired
    private IQualificationService qulificationService;

    @RequestMapping("/index")
    public ModelAndView select(){
        return new ModelAndView("qualification/index");
    }

    @RequestMapping("/list/{page}/{pageSize}")
    public Result findAll(@PathVariable int page, @PathVariable int pageSize, QualificationCondition condition){
        Result result = new Result();
        result.setObj(qulificationService.selectByCondition(page,pageSize,condition));
        return result;
    }



//    @RequestMapping("/toUpdate")
//    public ModelAndView toUpdate(){
//        return new ModelAndView("qualification/update");
//    }

//    @PutMapping("/doUpdate")
//    public Result doUpdate(@RequestBody Qualification qualification){
//        qualification.setUpdateDate(new Date());
//        qulificationService.updateByPrimaryKeySelective(qualification);
//        Result result = new Result(true,"更新成功",null);
//        return result;
//    }
//
//    @PostMapping("/insert")
//    public Result insert(@RequestBody Qualification qualification){
//        qualification.setCreateDate(new Date());
//        qualification.setUpdateDate(new Date());
//        qualification.setDelFlag("0");
//        qualification.setCreateBy("2,超级管理员");
//        qulificationService.insertSelective(qualification);
//        Result result = new Result(true,"插入成功",null);
//        return result;
//    }
//
//    @DeleteMapping("/delete/{id}")
//    public Result delete(@PathVariable String id){
//        Qualification qualification = new Qualification();
//        qualification.setId(Long.parseLong(id));
//        qualification.setUpdateDate(new Date());
//        qualification.setDelFlag("1");
//        qulificationService.updateByPrimaryKeySelective(qualification);
//        Result result = new Result(true,"删除成功",null);
//        return result;
//    }
}
